package com.longshihan.carservice.service.Article;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.longshihan.carservice.dao.AritcleDao;
import com.longshihan.carservice.model.ArticleDomain;
import com.longshihan.carservice.model.GoodsDomain;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ArticelServiceImpl implements ArticleService{

    @Autowired
    private AritcleDao aritcleDao;

    @Override
    public int addArticle(ArticleDomain articleDomain) {
        return aritcleDao.addArticle(articleDomain);
    }

    @Override
    public int delArticle(String authorId, String articleId) {
        return aritcleDao.delArticle(authorId,articleId);
    }

    @Override
    public int updateArticle(ArticleDomain articleDomain) {
        return aritcleDao.updateArticle(articleDomain);
    }

    @Override
    public PageInfo<ArticleDomain> getArticles(int pageNum, int pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        List<ArticleDomain> articleDomains = aritcleDao.getArticles();
        PageInfo<ArticleDomain> pageInfo = new PageInfo<>(articleDomains);
        return pageInfo;
    }

    @Override
    public ArticleDomain getArticleById(String authorId, String articleId) {
        return aritcleDao.getArticleById(authorId,articleId);
    }
}
